/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package filmlibrary.web;

import filmlibrary.orm.ORMHelper;
import filmlibrary.orm.classes.Films;
import java.util.List;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author karol
 */
@ManagedBean
@RequestScoped
public class AllFilmsBean {
    private static final Logger logger = Logger.getLogger("filmlibrary.web.AllFilmsBean");
    ORMHelper orm = new ORMHelper();
    List <Films> myfilms=null;
    /** Creates a new instance of FilmsBean */
    public AllFilmsBean() {
        myfilms = getFilmsFromDB();
    }
   
     private List<Films> getFilmsFromDB(){

        List<Films> lf = orm.getFilms();
        return lf;
    }

    public List<Films> getMyfilms() {
        return myfilms;
    }
    public List<Films> getNewFilms(){
        if(myfilms.size()>5)
            return myfilms.subList(myfilms.size()-5, myfilms.size());
        else
            return myfilms;
    }
     

}
